using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using net_work.Data.Entity.Sys;

namespace net_work.Config.DataBaseConfig.Sys;

/// <summary>
/// 教师实体配置类
/// </summary>
public class TeacherEntityTypeConfiguration : IEntityTypeConfiguration<Teacher>
{
    public void Configure(EntityTypeBuilder<Teacher> builder)
    {
        builder.ToTable("sys_tcr");

        builder.HasKey(t => t.Id);

        // 配置字段名映射
        builder.Property(t => t.Id).HasColumnName("tcr_id");
        builder.Property(t => t.TcrMajor).HasColumnName("tcr_major").IsRequired().HasMaxLength(32);
        builder.Property(t => t.TcrQual).HasColumnName("tcr_qual").IsRequired().HasMaxLength(256);
        builder.Property(t => t.TcrEduBg).HasColumnName("tcr_edu_bg").HasMaxLength(512);
        builder.Property(t => t.TcrWorkExp).HasColumnName("tcr_work_exp").HasMaxLength(512);
        builder.Property(t => t.TcrWorkAddr).HasColumnName("tcr_work_addr").HasMaxLength(128);
        builder.Property(t => t.TcrEmpDate).HasColumnName("tcr_emp_date").HasColumnType("date");
        builder.Property(t => t.ColleId).HasColumnName("colle_id").IsRequired();
        builder.Property(t => t.DepId).HasColumnName("dep_id");
        builder.Property(t => t.PsnId).HasColumnName("psn_id").IsRequired();

        builder.Property(t => t.CreatedBy).HasColumnName("create_by").IsRequired().HasMaxLength(64);
        builder.Property(t => t.CreatedTime).HasColumnName("create_time").IsRequired();
        builder.Property(t => t.UpdatedBy).HasColumnName("update_by").IsRequired().HasMaxLength(64);
        builder.Property(t => t.UpdatedTime).HasColumnName("update_time").IsRequired();
        builder.Property(t => t.Remark).HasColumnName("remark").HasMaxLength(256);
        builder.Property(t => t.DelFlag).HasColumnName("del_flag").HasDefaultValue('0');
    }
}